package com.xiaojf.xlog.appender.rdb.service.impl;

import com.xiaojf.xlog.appender.rdb.entity.AccessLog;
import com.xiaojf.xlog.appender.rdb.repository.AccessLogRepository;
import com.xiaojf.xlog.appender.rdb.service.AccessLogService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * 访问日志
 *
 * @author Ade.Xiao 2021/3/12 11:37
 */
@Service
public class AccessLogServiceImpl implements AccessLogService {
    private AccessLogRepository accessLogRepository;

    public AccessLogServiceImpl(AccessLogRepository accessLogRepository) {
        this.accessLogRepository = accessLogRepository;
    }

    @Override
    @Async("xlogAsyncTaskExecutor")
    public void save(AccessLog log) {
        if (log != null) {
            accessLogRepository.save(log);
        }
    }
}
